/*
   BaseControl.h
   
   Copyright (C) 2006 LinuxOne, Inc. <Republic of korea>

   This library is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as
   published by the Free Software Foundation; either version 2.1
   of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   Lessor General Public License for more details.

   You should have received a copy of the GNU Lessor General Public
   License along with this library; if not, write to the Free Software
   Foundation, inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

   Hyunjin Kim <mgc521@linuxone.co.kr>

   LinuxOne, Inc., hereby disclaims all copylight
   written by Hyunjin Kim, 20 December 2006
*/

#ifndef _BOOYO_POS_BASECONTROL_H_
#define _BOOYO_POS_BASECONTROL_H_

#include "BooyoPOSException.h"
#include "services/BaseService.h"
#include "const/BooyoPOSConst.h"
#include "events/BooyoPOSEvents.h"

namespace booyopos
{

class CBaseControl : public CBooyoPOSConst, public events::CBooyoPOSEvents
{
private:
protected:
	services::CBaseService *bs;
	bool			autoDisable;
	int				state;
	std::string		checkHealthText;
	bool			claimed;
	int				dataEventEnabled;
	bool 			deviceEnabled;
	bool			freezeEvents;
	int				outputID;

	std::string		deviceControlDescription;
	int				deviceControlVersion;

	bool			bOpen;

	services::CBaseService service;
public:
	CBaseControl();
	~CBaseControl();

	/* Properties */
	std::string GetCheckHealthText() throw (CByException);
	bool GetClaimed() throw (CByException);
	int GetState();
	std::string GetDeviceControlDescription();
	int GetDeviceControlVersion();
	bool GetDeviceEnabled() throw (CByException);
	void SetDeviceEnabled(bool deviceEnabled) throw (CByException);
	bool GetFreezeEvents() throw (CByException);
	void SetFreezeEvents(bool freezeEvents) throw (CByException);
	std::string GetDeviceServiceDescription() throw (CByException);
	int GetDeviceServiceVersion() throw (CByException);
	std::string GetPhysicalDeviceDescription() throw (CByException);
	std::string GetPhysicalDeviceName() throw (CByException);

	/* Methods */
	void Open(std::string logicalDeviceName) throw (CByException); // Opens a device for subsequent I/O
	void Close() throw (CByException);					// Releases the device and its resources
	void Claim(int timeout) throw (CByException); 		// Requests exclusive access to the device
	void Release() throw (CByException);					// Releases exclusive access to the device
	void CheckHealth(int level) throw (CByException); 	// Tests the state of a device
	void DirectIO(int command, int data, void* obj) throw (CByException); // Communicates directly with the UnifiedPOS Service
};

} // namespace booyopos

#endif // _BOOYO_POS_BASECONTROL_H_
